<?php
	DEFINE('H1', 'Pizza Selector Using Two Methods to Read an Array');
	DEFINE('TITLE','Pizza Choice Menu');
	require('includes/header.php');
?>	
	<h2><?PHP echo H1 ?></h2>

<?php
/***************************************************************
      Write your code for the particular assignment in this PHP block
***************************************************************/
	if(  !  isset($_POST['submit']))
	{
?>
<!-- HTML ZONE  -->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" >
	Select your favorite pizza toppints: <br />
	<input type="checkbox" name="toppings[]" value="tomato">Tomato</input>
	<input type="checkbox" name="toppings[]" value="onion">Onion</input>
	<input type="checkbox" name="toppings[]" value="jalapenos">Jalapenos</input>
	<input type="checkbox" name="toppings[]" value="olives">Olives</input>
	<input type="checkbox" name="toppings[]" value="mint">Mint</input>
	<input type="checkbox" name="toppings[]" value="pineapple">Pineappoe</input>
	<input type="checkbox" name="toppings[]" value="bacon">bacon</input>
	<input type="checkbox" name="toppings[]" value="chicken">Chicken</input>
	<input type="checkbox" name="toppings[]" value="ham">Ham</input>
	<input type="checkbox" name="toppings[]" value="anchovies">Anchovies</input>
	<input type="checkbox" name="toppings[]" value="X-cheese">Extra Cheese</input>
<br />
	<input type="submit" name="submit" value="Place Order" />

<?php
}  //end of the if( ! isset().......
else
{
?>
<h1>You selected</h1>
<ul>


<?php
	wrt("");
	wrt("Using a 'foreach' loop to see toppings...");
	wrt("Since we are only accessing the SINGLE toppings array this is the best way.");
	wrt("");
		foreach($_POST['toppings'] as $t) 
		{
			echo "<li>$t</li> \r \n";
		}
	wrt("");
	wrt("");
	wrt("Now we use a normal 'for loop' to see toppings...");
	wrt("");
	wrt("Since our MaintainMenu.php will be accessing 3 separate arrays (seq, choice, url) this is the best way.");
	wrt("");
	wrt("A single 'foreach' loop would not be able to iterate over 3 arrays at the same time.");
	wrt("");

		$ct = count($_POST['toppings']);
		for($ii =0; $ii < $ct; $ii++)
		{
			echo "<li>" . $_POST['toppings'][$ii] . "</li> \r \n";
		}

}  // end of the else clause
?>
</ul>

<?php
	require('includes/footer.php');
?>
)